@import '../page_bundles/mixins_and_variables_and_functions';
/**
 * Styles the GitLab application with a specific color theme
 */
@mixin gitlab-theme(
  $search-and-nav-links,
  $accent,
  $border-and-box-shadow,
  $navbar-theme-color,
  $navbar-theme-contrast-color
) {
  // Set custom properties

  --gl-theme-accent: #{$accent};

  $search-and-nav-links-a20: rgba($search-and-nav-links, 0.2);
  $search-and-nav-links-a30: rgba($search-and-nav-links, 0.3);
  $search-and-nav-links-a40: rgba($search-and-nav-links, 0.4);
  $search-and-nav-links-a80: rgba($search-and-nav-links, 0.8);

  // Header

  .navbar-gitlab {
    background-color: $navbar-theme-color;

    .navbar-collapse {
      color: $search-and-nav-links;
    }

    .container-fluid {
      .navbar-toggler {
        border-left: 1px solid lighten($border-and-box-shadow, 10%);
        color: $search-and-nav-links;
      }
    }

    .navbar-sub-nav,
    .navbar-nav {
      > li {
        > a,
        > button {
          &:hover,
          &:focus {
            background-color: $search-and-nav-links-a20;
          }
        }

        &.active,
        &.dropdown.show {
          > a,
          > button {
            color: $navbar-theme-color;
            background-color: $navbar-theme-contrast-color;
          }
        }

        &.line-separator {
          border-left: 1px solid $search-and-nav-links-a20;
        }
      }
    }

    .navbar-sub-nav {
      color: $search-and-nav-links;
    }

    .nav {
      > li {
        color: $search-and-nav-links;

        &.header-search {
          color: $gray-900;
        }

        > a {
          .notification-dot {
            border: 2px solid $navbar-theme-color;
          }

          &.header-help-dropdown-toggle {
            .notification-dot {
              background-color: $search-and-nav-links;
            }
          }

          &.header-user-dropdown-toggle {
            .header-user-avatar {
              border-color: $search-and-nav-links;
            }
          }

          &:hover,
          &:focus {
            @include media-breakpoint-up(sm) {
              background-color: $search-and-nav-links-a20;
            }

            svg {
              fill: currentColor;
            }

            .notification-dot {
              will-change: border-color, background-color;
              border-color: adjust-color($navbar-theme-color, $red: 33, $green: 33, $blue: 33);
            }

            &.header-help-dropdown-toggle .notification-dot {
              background-color: $white;
            }
          }
        }

        &.active > a,
        &.dropdown.show > a {
          color: $navbar-theme-color;
          background-color: $navbar-theme-contrast-color;

          &:hover {
            svg {
              fill: $navbar-theme-color;
            }
          }

          .notification-dot {
            border-color: $white;
          }

          &.header-help-dropdown-toggle {
            .notification-dot {
              background-color: $navbar-theme-color;
            }
          }
        }

        .impersonated-user,
        .impersonated-user:hover {
          svg {
            fill: $navbar-theme-color;
          }
        }
      }
    }
  }

  .navbar .title {
    > a {
      &:hover,
      &:focus {
        background-color: $search-and-nav-links-a20;
      }
    }
  }

  .header-search-form {
    background-color: $search-and-nav-links-a20 !important;
    border-radius: $border-radius-default;

    &:hover {
      background-color: $search-and-nav-links-a30 !important;
    }

    &.is-focused {
      input {
        background-color: $white;
        color: $gl-text-color !important;
        box-shadow: inset 0 0 0 1px $gray-900;

        &:focus {
          box-shadow: inset 0 0 0 1px $gray-900, 0 0 0 1px $white, 0 0 0 3px $blue-400;
        }

        &::placeholder {
          color: $gray-400;
        }
      }
    }

    svg.gl-search-box-by-type-search-icon {
      color: $search-and-nav-links-a80;
    }

    input {
      background-color: transparent;
      color: $search-and-nav-links-a80;
      box-shadow: inset 0 0 0 1px $search-and-nav-links-a40;

      &::placeholder {
        color: $search-and-nav-links-a80;
      }

      &:focus,
      &:active {
        &::placeholder {
          color: $gray-400;
        }
      }
    }

    .keyboard-shortcut-helper {
      color: $search-and-nav-links;
      background-color: $search-and-nav-links-a20;
    }
  }

  .search {
    form {
      background-color: $search-and-nav-links-a20;

      &:hover {
        background-color: $search-and-nav-links-a30;
      }
    }

    .search-input::placeholder {
      color: $search-and-nav-links-a80;
    }

    .search-input-wrap {
      .search-icon,
      .clear-icon {
        fill: $search-and-nav-links-a80;
      }
    }

    &.search-active {
      form {
        background-color: $white;
      }

      .search-input-wrap {
        .search-icon {
          fill: $search-and-nav-links-a80;
        }
      }
    }
  }

  .search-sidebar {
    .nav-link {
      &.active,
      &:hover {
        background-color: rgba($gray-50, 0.8);
        color: $gray-900;
      }
    }
  }

  // Sidebar
  .nav-sidebar li.active > a {
    color: $gray-900;
  }

  .nav-sidebar {
    .fly-out-top-item {
      a,
      a:hover,
      &.active a,
      .fly-out-top-item-container {
        background-color: var(--gray-100, $gray-50);
        color: var(--gray-900, $gray-900);
      }
    }
  }

  .branch-header-title {
    color: $border-and-box-shadow;
  }

  .ide-sidebar-link {
    &.active {
      color: $border-and-box-shadow;

      &.is-right {
        box-shadow: inset -3px 0 $border-and-box-shadow;
      }
    }
  }
}
